<template>
  <!-- 中铁2021年向审计署报送报表情况统计 -->
  <j-modal
    :title="'报表审批'"
    :width="800"
    :visible="visible"
    :maskClosable="false"
    :ok-button-props="{ props: { disabled: disableSubmit } }"
    :fullscreen="true"
    @close="close"
    cancelText="关闭"
  >
    <template slot="footer">
      <a-button key="back" style="padding-left: 20px; padding-right: 20px" @click="close()"> 关闭 </a-button>
      <a-popconfirm title="确定不通过吗?" style="width: 150px" @confirm="() => setApproveReason('2')">
        <a-button key="save" style="padding-left: 8px; padding-right: 8px"> 不通过 </a-button>
      </a-popconfirm>
      <a-popconfirm title="确定通过吗?" style="width: 150px" @confirm="() => setApproveReason('3')">
        <a-button key="submit" type="primary"> 通过 </a-button>
      </a-popconfirm>
    </template>
    <a-spin :spinning="Loading">
      <div :class="{ isCheck: isCheck }">
        <!-- <div class="table-header">
          <span class="table-title">填报单位：</span>{{ model.departName }} <span class="table-title">审计负责人：</span
          >{{ model.auditPersonName }} <span class="table-title">填表人：</span>{{ model.createByText }}
          <span class="table-title">填表时间：</span>{{ model.createTime }} <span class="table-title">统计时间：</span
          >{{ model.year }}年（{{ model.quarter }}季度）
        </div> -->
        <a-table
          class="edit-list"
          ref="table"
          size="middle"
          rowKey="id"
          bordered
          :columns="columns"
          :dataSource="dataSource"
          :pagination="false"
          :scroll="{ x: 250, y: '70vh' }"
        >
          <div slot="title">
            <div class="title">{{ title }}</div>
            <div class="sub-title">
              <div>填报单位：{{ model.departName }}</div>
              <div>{{ model.year }}年（{{ model.quarter }}季）度</div>
              <!-- <div>审计负责人：{{ model.auditPersonName }}</div>
              <div>填表人：{{ model.createByText }}</div>
              <div>填表时间：{{ model.createTime }}</div>
              <div>金额单位（万元）</div> -->
            </div>
          </div>
          <template v-slot:departName="text, record">
            <div style="width: 100%; height: 45px; overflow-x: hidden; overflow-y: auto">
              {{ record.departName }}
            </div>
          </template>
        </a-table>
      </div>
    </a-spin>
    <SetReason ref="setReason" @approveData="approveData"></SetReason>
  </j-modal>
</template>

<script>
import SetReason from '../SetReason'
import { BbspModelMixin } from './BbspModelMixin'
import { httpAction, getAction, postAction, deleteAction } from '@/api/manage'
import columns from './columns9'
export default {
  name: 'ModelView9',
  mixins: [BbspModelMixin],
  components: {
    SetReason,
  },
  data() {
    return {
      type: '7',
      reportType: '1',
      approveType: '1',
      state: '1',
      sjType: '7',
      columns: columns(),
      model: {},
      colrender: ['bsbbsl', 'wnrtjfwdw', 'jcxsw', 'qlzxdw', 'ytrmlkpzdw'],
      url: {
        list: '/sjxxzhbb/sjsbb/queryBsbbqktjInfoById',
        approve: '/common/sjProcCommon/auditApply',
      },
    }
  },
  methods: {
    // 审批
    approve(record) {
      this.Loading = true
      this.model = Object.assign({}, record)
      this.visible = true
      this.getTableData()
    },
    approveData(data) {
      this.Loading = true
      getAction(this.url.approve, {
        proId: this.model.id,
        state: this.approveType,
        sjType: this.sjType,
        reason: data,
      }).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
          this.Loading = false
          this.visible = false
          this.$emit('ok')
        } else {
          this.$message.error(res.message)
          this.Loading = false
        }
      })
    },
    getTableData() {
      this.Loading = true
      getAction(this.url.list, {
        id: this.model.id,
        sjType: this.sjType,
      }).then((res) => {
        if (res.success && res.result.length > 0) {
          this.dataSource = res.result[0].infoEntity || []
          this.model.createTime = res.result[0].createTime
          this.model.createByText = res.result[0].createByText
          this.model.auditPersonName = res.result[0].headName
          this.model.createBy = res.result[0].createBy
          this.model.departName = res.result[0].departName
          this.model.year = res.result[0].year
          this.model.quarter = res.result[0].quarter
          this.model.fileId = res.result[0].fileId
        }
        this.Loading = false
      })
    },
  },
}
</script>

<style lang="less" scoped>
// @import '../../../css/checkAndEdit.less';
@import '../../css/baobiaotable.less';

.table-header {
  margin-bottom: 10px;

  .table-title {
    font-weight: bold;
    margin-left: 15px;
  }
}
</style>